package ltd.dujiabao.springcloud.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import ltd.dujiabao.springcloud.entities.CommonResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : DuJiabao
 * @Project : springcloud
 * @Time : 2021/5/22 17:43
 * @Desc :
 */
@Api("TimeOut")
@Slf4j
@RestController
public class TimeOutController {
  @Value("${server.port}")
  private String serverPort;

  @GetMapping("/timeOut/{t}")
  public CommonResult<Object> timeOut(@PathVariable("t") int t) {
    try {
      log.info("睡" + t + "s, Port: " + serverPort);
      Thread.sleep(t * 1000L);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    return new CommonResult<>();
  }
}
